package com.cy.pj.common.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * 通过此类工具获取请求，相应等对象信息
 */
public class ServletUtil {
    /**
     * 获取请求对象
     */
    public static HttpServletRequest getRequest(){
        return getServletRequestAttributes().getRequest();
    }

    public static ServletRequestAttributes
                getServletRequestAttributes(){
        return (ServletRequestAttributes)
                RequestContextHolder.getRequestAttributes();
    }
}
